
class Field:
    def __init__(self, fieldName, fieldType='str'):
        __FIELD_VALUE_INIT = {'int':0, 'str':'', 'time':0, }
        self.fieldName = fieldName
        self.fieldType = fieldType
        self.value = __FIELD_VALUE_INIT[fieldType]
    def __str__(self):
        return str(self.value)
    def getName(self):
        return self.fieldName
    def getType(self):
        return self.fieldType
    
class Model(object):
    def __init__(self):
        self.dbName='db'
        self.tbName='tb'

class MGroup(Model):
    def __init__(self):
        self.id = Field(fieldName='id',fieldType='int')
        self.name = Field(fieldName='name')

class DBCommander(object):
    def __init__(self):
        pass
    
    def test(self):
        data = []
        for i in range(5):
            data.append((1,'fdsaf',0.23,False))
        return data
    
    def select(self, schema_array, sql):
        class data_type: pass
        #accessing database
        data = self.test()
        data_list = []
        for r in data:
            row = data_type()
            for i in range(len(schema_array)):
                setattr(row, schema_array[i], r[i])
            data_list.append(row)
        return data_list
    

class ModelParser:
    def __init__(self):
        pass
    
    def getInsertCmd(self):
        pass
    
    def getSelectCmd(self,schema,sql):
        
        pass

    def getUpdateCmd(self):
        pass

    def getDeleteCmd(self):
        pass


if __name__=='__main__':
    dbCmd = DBCommander()
    data_list = dbCmd.select(['id','name','rate','isOut'],'');
    for item in data_list:
        print 'id:%d, name:%s, rate:%f, isOut:%d',(item.id, item.name, item.rate, item.isOut)



    

